yjx.controller('todoOrdController', ['$rootScope', '$scope', 'ipCookie', '$timeout', '$fetch', 'modalService', function ($rootScope, $scope, ipCookie, $timeout, $fetch, modalService) {
    var api = '/order/stayPay';
    
    /**翻页处理 */
    $scope.temple = '<li class="orderItemLi" ng-repeat="item in dataList" ui-sref="orderDetail({id:item.orderId})"><order-item></order-item></li>';
    /**翻页处理 */
    var params = {
        limit: 10,
        offset: 1,
        tradeState:1
    }
    //$scope.paging = {};
    $scope.pageNum = 1;
    $scope.hideShows = true;
    //$scope._update = false;

    /*初始化获取数据*/
    function getOrderList() {
        $fetch.fetch(
            api,
            {
                params: params,
                cache:false,
            }
        ).then(function (data) {
            $timeout(function () {
                $scope.paging = data.page;
                $scope.dataList = data.list;
                //更新状态、数据加载控制
                $scope._updated = 'reupdated';
                $scope.hideShows = false;
            })
        }).catch(function (e) {
            modalService.mainMsgError(e.msg);
        })
    }
    /*翻页处理*/
    $scope.list = function () {
        params.offset = $scope.pageNum;
        $fetch.fetch(
            api,
            {
                params: params,
                cache: false,
            }
        ).then(function (data) {
            $timeout(function () {
                $scope.paging = data.page;
                $scope.dataList = $scope.dataList.concat(data.list);
                //更新状态、数据加载控制
                $scope._updated = 'updated';
                $scope.hideShows = false;
              
            })
        }).catch(function (e) {
            modalService.mainMsgError(e.msg);
        })
    }
    if($scope.$parent.curTab){
        getOrderList();
    }
}])